{include file="public/layout.htm" /}
<style type="text/css">
    .show {display: block;}
    .none {}
    .notic2 {
        font-size: 12px;
        line-height: 20px;
        color: #939799;
    }
</style>
<body class="back-c">
    <div class="ey-content">
        <form id="postForm">
            <input type="hidden" name="_ajax" value="1">
            <input type="hidden" name="weappAjax" value="1">
            <input type="hidden" name="order_id" value="{$orderData.order_id}">
            <input type="hidden" name="users_id" value="{$orderData.users_id}">
            <input type="hidden" name="order_code" value="{$orderData.order_code}">
            <input type="hidden" name="order_status" value="{$orderData.order_status}">
            <input type="hidden" name="actual_price" value="{$orderData.actual_price}">
            <input type="hidden" name="actual_points" value="{$orderData.actual_points}">
            <div class="item-wrap mt0">
                <div class="form-wrap more-wrap">
                    <div class="label">
                        <span>订单总额</span>
                    </div>
                    <div class="ey-input" style="white-space: unset;">
                        ￥{$orderData.order_total_amount}
                    </div>
                </div>

                {notempty name="$orderData.coupon_id"}
                <div class="form-wrap more-wrap">
                    <div class="label">
                        <span>优惠券</span>
                    </div>
                    <div class="ey-input" style="white-space: unset;">
                        -￥{$orderData.coupon_price}
                    </div>
                </div>
                {/notempty}
                {notempty name="$orderData.shipping_fee"}
                <div class="form-wrap more-wrap">
                    <div class="label">
                        <span>运费</span>
                    </div>
                    <div class="ey-input" style="white-space: unset;">
                        ￥{$orderData.shipping_fee}
                    </div>
                </div>
                {/notempty}
                <div class="form-wrap more-wrap">
                    <div class="label">
                        <span>实付总额</span>
                    </div>
                    <div class="ey-input" style="white-space: unset;">
                        ￥{$orderData.order_amount}
                    </div>
                </div>
                <div class="form-wrap more-wrap">
                    <div class="label">
                        <span>退款金额</span>
                    </div>
                    <div class="ey-input" style="white-space: unset;">
                        ￥{$orderData.actual_price}
                    </div>
                </div>
                
                {notempty name="$orderData.points_shop_order"}
                <div class="form-wrap more-wrap">
                    <div class="label">
                        <span>退还积分</span>
                    </div>
                    <div class="ey-input" style="white-space: unset;">
                        {$orderData.actual_points}积分
                    </div>
                </div>
                {/notempty}

                <div class="form-wrap more-wrap delivery-way">
                    <div class="label">
                        <span>退款方式</span>
                    </div>
                    <div class="selected">
                        <select class="pd0" name="refund_way" id="refund_way">
                            <option value="1" {eq name="$orderData.refund_way" value="1"} selected {/eq}>退款到余额{notempty name="$orderData.points_shop_order"}(积分){/notempty}</option>
                            <option value="2" {eq name="$orderData.refund_way" value="2"} selected {/eq}>线下退款</option>
                            <option value="3" {eq name="$orderData.refund_way" value="3"} selected {/eq} {neq name="$orderData.pay_name" value="wechat"} disabled {/neq}>原路退回(微信)</option>
                        </select>
                        <i class="iconfont icon-right"></i>
                    </div> 
                </div>

                <div class="form-wrap">
                    <div class="label">
                        <span>退款说明</span>
                    </div>
                    <div class="ey-input">
                        <div class="ey-input-wrapper">
                            <input type="text" value="" name="refund_remark"class="ey-input-input" placeholder="请输入退款说明">
                        </div>
                    </div>
                </div>
                <div class="form-wrap">
                    <p class="notic2">退款金额 = 订单总额 - 优惠券金额 - 本单已完成售后商品金额 - 运费</p>
                </div>
            </div>
        </form>
        <div class="w100-footer-wrap fixed-footer-wrap">
            <button class="w50-btn-no" id="unifiedJump" onclick="unifiedJump(this);" data-url="{:weapp_url('Mbackend/Shop/index', ['order_status' => $orderData.order_status])}">返回</button>
            <button class="w50-btn" onclick="submitOrderActiveRefund();">确认退款</button>
        </div>
    </div>

    <script type="text/javascript">
        // 表单提交
        function submitOrderActiveRefund() {
            if (!$('#refund_way:checked').val()) {
                layerAlert('请选择退款方式');
                return false;
            }
            layerLoading();
            $.ajax({
                type: "post",
                url : "{:url('Shop/order_active_refund')}",
                data: $('#postForm').serialize(),
                dataType: 'json',
                success: function (res) {
                    layer.closeAll();
                    if (1 === parseInt(res.code)) {
                        layerMsg(res.msg, 1, function() {
                            window.location.href = "{:weapp_url('Mbackend/Shop/index')}";
                        });
                        if (res.data.email) unifySendEmail(res.data.email);
                        if (res.data.mobile) unifySendMobile(res.data.mobile);
                        if (res.data.weChat) unifySendWeChat(res.data.weChat);
                    } else {
                        layerAlert(res.msg);
                    }
                },
                error:function(e){
                    layer.closeAll();
                    layerAlert(e.responseText);
                }
            });
        }
    </script>
</body>
{include file="public/footer.htm" /}